<!-- 首页的附近店铺组件 -->
<template>
  <div class="shop" v-for="item in shopList" :key="item._id" @click="$router.push({name:'detail',params:{id:item._id}})">
    <div class="shop-img">
      <img :src="item.imgUrl" :alt="item.name">
    </div>
    <div class="shop-info">
      <div class="shop-info-title">{{ item.name }}</div>
      <div class="shop-info-content">
        <span>月售{{ item.sales }}</span>
        <span>起送￥{{ item.expressLimit }}</span>
        <span>基础运费￥{{ item.expressPrice }}</span>
      </div>
      <div class="shop-info-tag">{{ item.slogan }}</div>
      <div class="shop-info-line"></div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue';
import { get } from '@/utils/request';
import { SHOP } from '@/api/interface'
// 获取店铺数据
const useShopRequest = () => {
  let shopList = ref([]);
  const request = async () => {
    try {
      shopList.value = (await get(SHOP)).data
    } catch (error) {
      console.log(error);
    }
  }
  request();
  return { shopList }
}
// composition
export default {
  name: 'nearby',
  setup() {
    const { shopList } = useShopRequest();
    return { shopList };
  }
}
</script>

<style scoped lang="scss">
@import '@/styles/theme.scss';

.shop {
  padding: 12px 0;
  display: flex;

  &-img {
    width: 14.9333vw;
    margin-right: 4.2667vw;

    img {
      width: 100%;
    }
  }

  &-info {
    flex: auto;
    color: $theme-font-color;

    &-title {
      font-size: 16px;
      margin-bottom: 2.1333vw;
    }

    &-content {
      font-size: 13px;
      margin-bottom: 2.1333vw;

      span {
        margin-right: 4.2667vw;
      }
    }

    &-tag {
      font-size: 13px;
      color: $remind-color;
    }

    &-line {
      height: 1px;
      background-color: #f1f1f1;
      position: relative;
      top: 13px;
    }
  }
}
</style>